/**函数式组件开发的精髓就在于可以抽象独立的逻辑做为复用,命名规则为useXXX */

import {reactive,onMounted,onBeforeUnmount} from 'vue'
export default function () {
    //点击坐标
    let point = reactive({
        x:0,
        y:0
    })
    function savePoint(e) {
        point.x = e.pageX
        point.y = e.pageY
        console.log(e.pageX,e.pageY)
    }
    //获取坐标(事件监听)
    onMounted(()=>{
        window.addEventListener('click',savePoint)
    })
    onBeforeUnmount(()=>{
        window.removeEventListener('click',savePoint)
    })
    return point
}
